package org.ihelpuoo.weboo.checkers;

import org.ihelpuoo.lang.LoaderException;
import org.ihelpuoo.lang.StringUtils;
import org.ihelpuoo.util.IntegerRange;

public class TextLengthChecker extends AbstractChecker
{

	private IntegerRange	ir;

	public boolean isValid(String value)
	{
		if (StringUtils.isEmpty(value))
			return true;
		if (!ir.isInRange(StringUtils.len(value)))
			return false;
		return true;
	}

	public void setSetting(String setting)
	{
		try
		{
			ir = new IntegerRange(StringUtils.trim(setting));
		}
		catch (LoaderException e)
		{
			throw new RuntimeException(e);
		}
	}

}
